local hanchao = fk.CreateSkill {
  name = "th_hanchao",
  tags = { Skill.Limited },
}

hanchao:addEffect(fk.EventPhaseProceeding, {
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(hanchao.name) and player.phase == Player.Start and
    self:withinTimesLimit(player, Player.HistoryGame) and player:getLostHp() > 0
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local targets = room:getOtherPlayers(player)
    for _, p in ipairs(targets) do
      local nDiscard = 2 + player:getLostHp()
      local cards = room:askToDiscard(p, {
        min_num = nDiscard,
        max_num = nDiscard,
        include_equip = true,
        skill_name = hanchao.name,
        prompt = "#th_hanchao_discard-ask:::" .. nDiscard,
        skip = true,
      })
      if #cards < nDiscard then
        room:setPlayerMark(p, "@@th_hanchao", 1)
        room:setPlayerMark(p, "_th_hanchao-turn", 1)
        p:turnOver()
      else
        room:throwCard(cards, hanchao.name, p, p)
      end
    end
  end,
}, { check_skill_limit = true })
hanchao:addEffect(fk.PreCardEffect, {
  can_refresh = function(self, event, target, player, data)
    return player:getMark("@@th_hanchao") ~= 0
  end,
  on_refresh = function(self, event, target, player, data)
    data:setDisresponsive(player)
  end,
})
hanchao:addEffect(fk.TurnEnd, {
  can_refresh = function(self, event, target, player, data)
    return target == player and player:getMark("_th_hanchao-turn") == 0
  end,
  on_refresh = function(self, event, target, player, data)
    local room = player.room
    room:setPlayerMark(player, "@@th_hanchao", 0)
  end,
})

Fk:loadTranslationTable{
  ["th_hanchao"] = "寒潮",
  [":th_hanchao"] = "限定技，准备阶段，若你已受伤，你可以令所有其他角色依次选择一项：1.弃置X张牌（X为你已损失的体力值+2）；2.翻面，且不可响应牌直到其回合结束。",

  ["#th_hanchao_discard-ask"] = "寒潮：你须弃置%arg张牌，否则你翻面，且不可响应牌直到其回合结束",
  ["@@th_hanchao"] = "寒潮",
}

return hanchao